< previous page page_332 next page >

Page 332
Using the Immediate Window
In break mode, you can bring up the Immediate window and perform statements. These statements can be any valid Visual Basic expression. For example, you can print the results of an operation, print the contents of a variable or property, and even set the value of a variable or property. Figure 16.10 shows the Immediate window.
8160-0332a.gif
Figure 16.10
The Immediate window.
Notice that you can use a question mark (?) instead of the keyword Print.
Printing to the Immediate Window
Many times during the testing of your application, you may find that when youre stepping through code, it works fine, but when you run the program straight through, it doesnt work. The reason for this is because you can change the way your program runs by using the debugger. Every time you switch from your program to the debugger, youre inadvertently firing events. Because different events fire during this process, they change how your program normally runs. Therefore, instead of using the debugger to test values, you may find it convenient to print these values to the Immediate window.
You can print directly to the Immediate window from within your application by executing the Debug.Print method. These values will stay around even when you return back to design mode. It can be useful to see these intermediate values without having to enter break mode and change the execution of your program. Heres an example of using the Debug.Print method:
9f31265bb40b592b1929e18a47ab28e5.gif
Debug.Print "strMyString = " ; strMyString
Debug.Print "I am now executing the Form_Click() procedure"

 
< previous page page_332 next page >

If you like this book, buy it!